<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">
        
        <h3>Rewards Manager</h3>
        <br/>
        <br/>
        
                <h5>Current Rewards</h5><br/>
                <div>
                            <h:form>
                                    <br/>
                                    <br/>
                                    <p:dataTable value="#{rewardMB.getStakeholderItems()}" var="o"
                                         styleClass="order-table-shoppingcart"
                                         rowStyleClass="contentbox"
                                         emptyMessage="You have no rewards created"
                                         >



                                        <p:column style="width: 10px">
                                            <f:facet name="header">ID</f:facet>
                                            #{o.id}
                                        </p:column>

                                        <p:column style="width: 50px">
                                            <f:facet name="header">Name</f:facet>
                                            #{o.reward_Name}
                                        </p:column>

                                        <p:column style="width: 80px">
                                            <f:facet name="header">Description</f:facet>
                                            <h:outputText value="#{o.reward_Description}" escape="false"/>

                                        </p:column>

                                        <p:column style="width: 40px">
                                            <f:facet name="header">Points Cost</f:facet>
                                            #{o.reward_Cost}
                                        </p:column>

                                        <p:column style="width: 40px">
                                            <f:facet name="header">Vouchers Left</f:facet>
                                            #{o.getRemainingVouchers()}
                                        </p:column>


                                        <p:column style="width: 50px">                    
                                            <p:commandButton value="Remove" action="#{rewardMB.deleteReward(o)}" ajax="false"/>
                                        </p:column>


                                    </p:dataTable>

                            </h:form>   
                    </div>



                <br/>
                <br/>
                <br/>
                <h5>Add new Reward Item</h5><br/>
                <h:form>                   
                    <h:panelGrid columns="3">

                        <h:outputLabel for="rewardName" value="Reward name &nbsp;"/>
                            <p:inputText required="true" requiredMessage="Reward name is requied!"
                                 id="rewardName" value="#{rewardMB.reward_Name}"/>
                            <p:message for="rewardName"/>


                            <h:outputLabel for="rewardDesc" value="Reward description &nbsp;"/>
                            <p:inputTextarea required="true" requiredMessage="Reward description is requied!"
                                 id="rewardDesc" value="#{rewardMB.reward_Description}"/>
                            <p:message for="rewardDesc"/>


                            <h:outputLabel for="rewardCost" value="Reward cost &nbsp;"/>
                            <p:inputText required="true" requiredMessage="Reward cost is requied!"
                                 id="rewardCost" value="#{rewardMB.reward_Cost}"/>
                            <p:message for="rewardCost"/>         


                            <h:outputLabel for="numVouchers" value="Vouchers Amount &nbsp;"/>
                            <p:inputText id="numVouchers" value="#{rewardMB.vouchers_left}" required="true">
                                    <f:validateLongRange minimum="1"/> 
                            </p:inputText>
                            <p:message for="numVouchers"/>    
                     </h:panelGrid>
                        <h:outputLabel value="Unlimited Vouchers"/>
                        <h:selectBooleanCheckbox value="#{rewardMB.unlimitedVouchers}"/>

                    <br/>
                    NOTE: If unlimited vouchers is checked, the system will ignore the Vouchers Amount input.
                    <br/>
                    <br/>
                    <h:commandButton action="#{rewardMB.createReward()}" value="Create Reward Item"/>
        </h:form>  
        

    </ui:define>

</ui:composition>


